﻿using System.Linq;
using System.Collections.Generic;

namespace Inovout.Gis.Land.XZQMap
{
    public class XZQMap:MapObject
    {
        public XZQMap()
        {
        }
        private SortedList<int,string> grainedLayerDescriptors;
        internal SortedList<int, string> GrainedLayerDescriptors
        {
            get 
            {
                if (grainedLayerDescriptors == null)
                {
                    grainedLayerDescriptors = new SortedList<int, string>();
                    grainedLayerDescriptors.Add(1, "G11_H_PY");
                    grainedLayerDescriptors.Add(2, "G12_H_PY");
                    grainedLayerDescriptors.Add(3, "G13_H_PY");
                }
                return grainedLayerDescriptors;
            }
        }
        public override void Build(Configuration config)
        {
            config.AddLayerMapping(this.GetType(), typeof(XZQPolygonLayer),typeof(XZQPolygon),GrainedLayerDescriptors.Values.ToArray());
        }
        private XZQPolygonLayer topXZQLayer;
        public XZQPolygonLayer TopXZQLayer
        {
            get 
            {
                if (topXZQLayer == null)
                {
                    KeyValuePair<int,string> topXZQLayerDescriptor = grainedLayerDescriptors.First();
                    topXZQLayer = base.Layers.Single(layer => layer.Name.Equals(topXZQLayerDescriptor.Value)) as XZQPolygonLayer;
                    topXZQLayer.Map = this;
                    topXZQLayer.Level = topXZQLayerDescriptor.Key;
                }
                return topXZQLayer;
            }
        }

    }
}
